<% 
	if (session.getAttribute("admin") == null) {
		response.sendRedirect("/kaola/admin/login.jsp");
	}
%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'update_product.jsp' starting page</title>
</head>

<body>
	<s:property value="errors['product.name'][0]"/><br/>
	<s:property value="errors['product.price'][0]"/>
	<a href="/kaola/admin/manage.jsp">管理者主页</a>
	<form action="/kaola/products/update" method="post">
		<table>
			<tr>
				<td>name:</td>
				<td>
					<input type="text" name="product.name" value="${product.name}" />
				</td>
			</tr>
			<tr>
				<td>price:</td>
				<td>
					<input type="number" name="product.price" value="${product.price}" />
				</td>
			</tr>
			<tr>
				<td>inventory:</td>
				<td>
					<input type="number" name="product.inventory" value="${product.inventory}" />
				</td>
			</tr>
			<tr>
				<td>category:</td>
				<td>
					<s:select list="categories" listKey="id" listValue="name" name="product.category.id" value="product.category.id"></s:select>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<input type="hidden" name="product.id" value="${product.id}" />
					<input type="hidden" name="product.createAt" value="${product.createAt}" />
					<input type="hidden" name="product.version" value="${product.version}" />
					<button type="submit">update product</button>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
